var start = 1;
var limit = 10;
mui.init();
mui.plusReady(function() {
	initData();
	initListener();
})

window.addEventListener("reloadView", function() {
	start = 1;
	$("#ul_mysheet").html("");
	getMore();
})
mui("#div_addMore")[0].addEventListener("tap", function() {
	getMore();
});

function getMore() {
	var url = "/sdxsms/sdxsMissionPageController/getEvent.do";
	plus.nativeUI.showWaiting();
	var sss = {
		"start": start,
		"limit": limit,
		"state": 0
	}
	ajaxF1(url, sss, function(result) {
		console.log(JSON.stringify(result));
		var $myOrder11 = $("#mylist").find('li').eq(0);
		var data = result.resultValue;
		for(var i in data) {
			var $myOrder = $myOrder11.clone();
			$myOrder.attr("ID", data[i].ID);
			$myOrder.find(".datame").html(JSON.stringify(data[i]));
			$myOrder.find(".span_bt").eq(0).html(data[i].SJTITLE);
			$myOrder.find(".span_ms").eq(0).html(data[i].SJMS)
			$myOrder.find(".span_rq").eq(0).html(data[i].LOGINDATE)
			switch(data[i].SJLX) {
				case '10001': //事件
					break;
				case '10002': //告警
					$myOrder.find(".span_voice").removeClass("icon-roundadd").addClass("icon-iconiconcopy");
					break;
			}

			$("#ul_mysheet").append($myOrder);
		}
		if(data && data.length === limit) {
			start += 1;
			if(mui("#div_addMore")[0].classList.contains("mui-hidden")) {
				mui("#div_addMore")[0].classList.remove("mui-hidden")
			}
		} else {
			if(!mui("#div_addMore")[0].classList.contains("mui-hidden")) {
				mui("#div_addMore")[0].classList.add("mui-hidden")
			}
		}
		plus.nativeUI.closeWaiting();
	}, function() {
		mui.toast("请求失败");
		plus.nativeUI.closeWaiting();

	});

};

function initData() {
	start = 1;
	$("#ul_mysheet").html("");
	getMore();
}

function initListener() {
	$("#ul_mysheet").on("tap", "li", function() {
		var ID = $(this).attr("ID");
		jumpTo("../eventdetail/eventdetail.html", "eventdetail.html", JUMP_DURATION_TIME, {
			"ID": ID,
			"item": $(this).find(".datame").html()
		})
	})
}